package cn.zh.stan.adapter;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lzy.okhttputils.OkHttpUtils;
import com.lzy.okhttputils.callback.StringCallback;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

import cn.zh.stan.BaseUrl;
import cn.zh.stan.ITem.CAItem;
import cn.zh.stan.R;
import cn.zh.stan.util.ToastUtil;
import okhttp3.Call;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by WYN on 2018/2/5 0005.
 */

public class FAdapter extends BaseAdapter{
    Context context;
    ArrayList<CAItem> arrayList;
    LayoutInflater inflater;

    public FAdapter(Context context,ArrayList<CAItem> arrayList){
        this.context=context;
        this.arrayList=arrayList;
        inflater=LayoutInflater.from(context);
    }


    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return arrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
       Holder holder=null;
        if (null==view){
            holder=new Holder();
            view=inflater.inflate(R.layout.fa_layout,null,false);
            holder.caimg=view.findViewById(R.id.caimg);

            holder.cttxt=view.findViewById(R.id.cttxt);
            holder.cuint=view.findViewById(R.id.cuint);
            holder.caprice=view.findViewById(R.id.caprice);
            holder.cetxt=view.findViewById(R.id.cetxt);
            view.setTag(holder);
        }else {
            holder= (Holder) view.getTag();
        }
        holder.cttxt.setText(arrayList.get(i).getGoodsName());
        holder.cuint.setText("单位:"+arrayList.get(i).getUnit());
        holder.caprice.setText("¥"+arrayList.get(i).getPrice_Detail());
        holder.cetxt.setText("x"+arrayList.get(i).getNum());

        if (arrayList.get(i).isType()){

        }else {

        }

        return view;
    }




    class  Holder {
        ImageView caimg;
        TextView cttxt,cuint,caprice,cetxt;
    }





}
